package curso.avanzado.android.listener;

import curso.avanzado.android.DetalleActivity;
import curso.avanzado.android.R;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;

public class ContactosOnItemClickListener implements OnItemClickListener {
	
	private Activity activity;
	
	public ContactosOnItemClickListener(Activity activity) {
		super();
		this.activity = activity;
	}

	public void onNothingSelected(AdapterView<?> arg0) {
	    // No hacer nada
	}

	public void onItemClick(AdapterView<?> parent, View view, int pos,
		long id) {

	    TextView tvId = (TextView) view.findViewById(R.id.tvItemId);

	    Intent intent = new Intent(activity.getApplicationContext(),
		    DetalleActivity.class);
	    intent.putExtra("idContacto", tvId.getText().toString());
	    activity.startActivity(intent);
	}

}
